<?php


namespace App\Http\Controllers;


class AdminBaseController extends BaseController
{
    /**
     * 列表入口
     * @return mixed
     */
    public function index()
    {
//        if( !request()->ajax())
//        {
//            return view(VIEW_NAME);
//        }
        return $this->lists();
    }

    /**
     * 表单入口
     */
    public function form()
    {
        if (request()->ajax()) {
            return $this->store();
        }
        return view(VIEW_NAME);
    }


    /**
     *  修改状态
     */
    public function lock()
    {
        $result = $this->services->lock();
        if ($result) {
            return $this->success(null, $this->services->getInfo('成功'));
        } else {
            return $this->failure($this->services->getError());
        }
    }

//    /**
//     * 成功返回
//     * @param string $msg
//     * @param $data array
//     * @param string $url
//     * @return \Illuminate\Http\JsonResponse
//     */
//    protected function success($data = null,$msg = '成功', $url = '')
//    {
//        return response()->json([
//            'code' => Handler::SUCCESS_CODE,
//            'msg' => $msg,
//            'data' => $data,
//            'url' => $url,
//            'http_code'=>Handler::STATUS_NORMAL
//        ], Handler::STATUS_NORMAL, array(), JSON_UNESCAPED_UNICODE);
//    }

}
